Repository navigation
Share test stubs, and show a per-node style in the styles example - #543
Merged
Merged
Conversation
Add test/include/TestDelegateModels.hpp with StubDelegateModel. It takes a name, a caption and the port counts. Six tests now use it or derive from it instead of repeating the seven overrides: TestDataFlowGraphModel, TestSerialization, TestNodeGroup, TestNodeNickname, TestNodeStyleRole and TestNodeValidation. StyledModel and TestValidatedModel lose Q_OBJECT and their .moc includes. They have no signals or slots of their own. Add test/include/LockableModel.hpp with the template LockableModel<Base>. It replaces the two lockable models in TestLockedNodePress and TestNodeGroup. The lock is now kept per node in both. Registry setup stays in each test. TestModelWithName, TestModelWithStaticName and EagerWidgetModel stay local. Behavior is unchanged: 69 test cases and 761 assertions, with the same per-section counts as before. Net change: -6 lines. Fixes #553
Issue #87 asks for an example of a custom per-node style. The styles example now has a second node type, MyGreenDataModel. Its delegate model sets its own background and border color with setNodeStyle(). It looks different from MyDataModel, which uses the global style. The example starts with two nodes of each type side by side. The styling guide points to this example.
paceholder
force-pushed
the
example/per-node-style
branch
from
November 23, 2026 00:50
2c8e577 to
e8bbc08
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
Two commits. The first is a test-only refactor. The second shows a per-node style in an example.
NodeDelegateModelin many small classes, and had two lockable models. They now use two header-only files:test/include/TestDelegateModels.hpp(StubDelegateModel, with name, caption and port counts as constructor parameters) andtest/include/LockableModel.hpp(LockableModel<Base>, which replacesLockableGraphModeland the oldLockableModel). Six test files use the stub. Registry setup stays in each test. Behavior is unchanged. The net size of the tests is about the same (-6 lines): the new headers are as long as what was removed, and each plain stub still needs a small creator function for registration. The gain is that a new test can derive from the stub instead of copying the block.examples/stylesnow has a second node type,MyGreenDataModel. Its delegate model callssetNodeStyle()in the constructor, so it keeps its own green style next to the global one. The example starts with two nodes of each type. The "Per-Node Styling" section of the styling guide points to it. The example is the right place for it:simple_graph_modelis meant to show the model itself, so I did not change it.Testing
stylesexample was checked with an offscreen screenshot: mint nodes with a gray border (global style) next to green nodes with a green border (per-node style).-Werror(CI covers them).Breaking changes?
No. Tests, one example and one docs section only.
Related issue
Fixes #553
Related to #87.